"""
第 0000 题：将你的 QQ 头像（或者微博头像）右上角加上红色的数字，类似于微信未读信息数量那种提示效果
"""
from  PIL import Image,ImageDraw,ImageFont
import sys

def add_num_to_img(file_path):
    im = Image.open(file_path)
    im_drow = ImageDraw.Draw(im)
    x,y = im.size()
    font = ImageFont.truetype('arial.ttf',int(im.size[0]/5))
    im_drow.text((int(im.size[0]-im.size[0]/10), 5),'3',(256,0,0),font=font)
    im.save('new.png')
    del  im_drow

if __name__ == '__main__':
    if len(sys.argv) <=1:
        print("Need at least 1 parameter. Try to execute 'python 0000.py $image_path'")
    else:
        for infile in sys.argv[1:]:
            try:
                add_num_to_img(infile)
                print('success')
            except IOError:
                print('can not open image')
                pass